#include "Parser.h"
#include <igloo/igloo.h>
#include <string>
using namespace igloo;


Context(parserTest){

	Parser* parser;
	string* filePath;

	void SetUp() {
		filePath = new string("/home/maruuchis/Dan Brown - Ángeles y Demonios.txt");
		parser = new Parser();
	}

	Spec(returnsFileName){
		Assert::That(parser->ExtractFilename(filePath), Is().EqualTo("Dan Brown - Ángeles y Demonios.txt"));
	}
	Spec(ifIsStopwordReturnsTrue){
			Assert:: That(!parser->isStopWord("Borges"));
	}
	Spec(eraseSymbolsFromAWord){
				string word = "((::H??ola!,";
				parser->eraseSymbols(word);
				Assert:: That(word,Is().EqualTo("Hola"));
	}
	Spec(returnsBook){
		string author = "Dan Brown";
		string title = "Ángeles y Demonios";

		Book* book = new Book();
		book->setAuthor(&author);
		book->setTitle(&title);

		Book* result = parser->parseBook(filePath);

		Assert::That(*(book->getTitle()),Is().EqualTo(*(result->getTitle())));
		Assert::That(*(book->getAuthor()),Is().EqualTo((*result->getAuthor())));
	}

	Spec(FileNoFound){
		bool isNull = false;
		string* filePath2 = new string("/home/maruuchis/Dan Brown - Ángeles y Demonios.");
		Book* result = parser->parseBook(filePath2);

		if (result == NULL) isNull = true;

		Assert::That(isNull);
	}

};

int main() {
	return TestRunner::RunAllTests();
}
